package com.dx.financehy.modules.homePage.rest;

import com.dx.financehy.annotation.rest.AnonymousPostMapping;
import com.dx.financehy.modules.business.service.BusinessService;
import com.dx.financehy.modules.platformClassOne.domain.PlatformClassOne;
import com.dx.financehy.modules.platformClassOne.domain.dto.GetPlatformClassDTO;
import com.dx.financehy.modules.schedule.domain.dto.GetScheduleDTO;
import com.dx.financehy.modules.schedule.domain.vo.ScheduleVO;
import com.dx.financehy.modules.schedule.service.ScheduleService;
import com.dx.financehy.modules.system.domain.vo.BusinessVO;
import com.dx.financehy.modules.system.service.UserService;
import com.dx.financehy.modules.touristMessages.domain.dto.AddTouristMessagesDTO;
import com.dx.financehy.modules.touristMessages.service.TouristMessagesService;
import com.dx.financehy.utils.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: huang_jigao
 * @Title: HomePageController
 * @ProjectName: financehy
 * @Description:
 * @date: 2024-05-16 8:48
 */
@Api(tags = "首页")
@RestController
@RequestMapping("/homePage")
@RequiredArgsConstructor
@Slf4j
public class HomePageController {

    private final BusinessService businessService;

    private final TouristMessagesService touristMessagesService;

    private final UserService userService;

    private final ScheduleService scheduleService;

    @ApiOperationSupport(author = "黄基高")
    @ApiOperation(value = "获取待办事项")
    @PostMapping("/getScheduleList")
    public R<PageInfo<ScheduleVO>> getScheduleList(@RequestBody @Validated GetScheduleDTO req) {
        PageHelper.startPage(req.getPage(), req.getSize());
        List<ScheduleVO> list = scheduleService.getList(req);
        return R.ok(new PageInfo<>(list));
    }

    @ApiOperation(value = "移动端首页")
    @GetMapping(value = "/getBusinessHomePage")
    public R<List<BusinessVO>> getBusinessHomePage(@RequestParam String userId) {
        return R.ok(businessService.getBusinessHomePage(userId));
    }

    @ApiOperationSupport(author = "itHuang")
    @ApiOperation(value = "新增留言")
    @PostMapping("/addTouristMessages")
    public R addTouristMessages(@RequestBody @Validated AddTouristMessagesDTO dto) {
        touristMessagesService.addTouristMessages(dto);
        return R.ok();
    }

    @ApiOperationSupport(author = "黄基高")
    @ApiOperation(value = "获取平台资源")
    @AnonymousPostMapping("/getAllPlatformClassList")
    public R<PageInfo<PlatformClassOne>> getAllPlatformClassList(@RequestBody @Validated GetPlatformClassDTO dto) {
        PageHelper.startPage(dto.getPage(), dto.getSize());
        List<PlatformClassOne> list = userService.getAllPlatformClassList(dto);
        return R.ok(new PageInfo<>(list));
    }
}
